package com.ytf.test.seventh;

/**
 * @author: YTF
 * @date: 2024/11/6 16:25
 * @version: 1.0
 * @description:
 */
public class Orc extends Villain {
    private int orcNumber;
    public Orc(String name,int orcNumber) {
        super(name);
        this.orcNumber = orcNumber;
    }
    public void change(String name,int orcNumber){
        // super.set(name);
        set(name);
        this.orcNumber = orcNumber;
    }

    @Override
    public String toString() {
        return "Orc{" +
                "orcNumber=" + orcNumber +
                "name=" + super.toString() +
                '}';
    }

    public static void main(String[] args) {
        Orc orc = new Orc("Limburger",12);
        System.out.println(orc);
        orc.change("Bob",19);
        System.out.println(orc);

        /**
         * Output:
         * Orc{orcNumber=12name=Villain{name='Limburger'}}
         * Orc{orcNumber=19name=Villain{name='Bob'}}
         *
         * 总结:
         *  注意包的访问权限，确定范围和使用方式
         */
    }
}
class Villain{
    private String name;
    protected void set(String name){
        this.name = name;
    }
    public Villain(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Villain{" +
                "name='" + name + '\'' +
                '}';
    }
}
